package com.gpipe.dirwatcherRealtime;

import com.gpipe.tools.AmountSum;
import com.gpipe.tools.ODList;
import com.gpipe.tools.SignalList;

import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;

/*
 * author:zhengrx
 * function:this class is used to store the map that contains basestations and accnbr 
 * and the map that contains basestations and count of accnbr.
 */
public class DirectorySnapshotRealtime {

	//timeperiod 的开始时间
	public static String periodBeginTime = "0000";
	//timeperiod 的结束时间
	public static String periodEndTime = new String();

	//ODSumProcess()中，实时模式记录上次跑了的timePeriod
	public static String periodFlag = new String();

	//fileName:timeStampe -- second period
	public static Map<String,Long> fileSnapshot = new HashMap<String, Long>();

	//记录清单层一天全量数据nbr:Object(lac|ci|nbr|starttime|endtime|duration) -- second period--准备弃用
	public static Map<String,List<SignalList>> listSumRecords = new HashMap<String, List<SignalList>>();
	//记录清单层每周期（15分钟）的数据nbr:Object(lac|ci|nbr|starttime|endtime|duration) -- second period
	public static Map<String,List<SignalList>> listSumPeriodRecords = new HashMap<String, List<SignalList>>();
	//记录清单层增量数据nbr:Object(lac|ci|nbr|starttime|endtime|duration) -- second period
	public static Map<String,List<SignalList>> listSumIncreRecords = new HashMap<String, List<SignalList>>();
	//记录OD逻辑中周期的最后一条记录nbr:Object(lac|ci|nbr|starttime|endtime|duration) -- second period
//	public static Map<String,List<SignalList>> tmpListSumIncreRecords = new HashMap<String, List<SignalList>>();
	//记录OD清单增量数据nbr:ODList -- second period
	public static Map<String,List<ODList>> ODListcreRecords = new HashMap<String, List<ODList>>();
	//记录集散量的记录 -- second period--lacciO|lacciD:amountsum
	public static Map<String,AmountSum> amountSumRecords = new HashMap<String, AmountSum>();





	//lac|ci|nbr:lac|ci|nbr
//	public static Map<String,String> records = new HashMap<String, String>();
	public static ConcurrentHashMap<String, String> records = new ConcurrentHashMap<String, String>(); 
	//longitude|latitude:nbrCount
	public static Map<String,Integer> results = new HashMap<String, Integer>();
	//lac|ci:nbrCount
	public static Map<String,Integer> midResults = new HashMap<String, Integer>();
	//longitude|latitude|nbr:longitude|latitude|nbr----(table 1.2)
	public static Map<String,String> nbrLongLaRes = new HashMap<String, String>();
	//filename:filename
	public static Map<String,String> oneHourFiles = new HashMap<String,String>();
	//nbr:lac|ci|duration----(table 2.1)
	public static Map<String,String> baseNbrArea = new HashMap<String,String>();
	//longitude|latitude|area:nbrCount----(table 2.2)
	public static Map<String,Integer> longLaArea = new HashMap<String,Integer>();
	//nbr:area|duration----(table 2.1 of first period simple)  
	public static Map<String,String> NbrArea = new HashMap<String,String>();
		
	//the interval of go and come
	public static final int statInterval = 3600;
	//the goFileTime of successfully generating go data  
	public static String goFileTimeBefore = null;
	//mobile proportion of guangzhou china telecom
	public static final double proportion = 0.141;
	//ftp shell's name
	public static final String ftpShell = "ftp.sh";
	///home/zhengrx,according to the path of jar
	public static String homePath = null;
	
	public static String fileNameSuffix = null;
	
	public static void addFile(String fileName){
		oneHourFiles.put(fileName, fileName);
    }

    public static void removeFile(String fileName){
    	oneHourFiles.remove(fileName);
    }

    public static boolean containsFile(String fileName){
        return oneHourFiles.containsKey(fileName);
    }
	
	public static void addRecord(String baseNbr){
		records.put(baseNbr, baseNbr);
    }

	public static void removeRecord(String baseNbr){
		records.remove(baseNbr);
    }

    public static boolean containsRecord(String baseNbr){
        return records.containsKey(baseNbr);
    }
    
    public static void addResult(String longLa,int nbrCount){
    	results.put(longLa, nbrCount);
    }

	public static void removeResult(String longLa){
		results.remove(longLa);
    }

    public static boolean containsResult(String longLa){
        return results.containsKey(longLa);
    }
}
